<?php
namespace Admin\Model;
use Think\Model;
class ProvinceModel extends Model {
	public $page; //当前页
	public $perpage; //每页显示
	public $province_id; //ID
	public $post; //提交的信息 数组
	public $table='zjy_province';
	public $ids; //IDs 数组，用于删除

	//获取列表
	public function get_province_list()
	{
		$Model=M("Province");
		$list=$Model->query("select province_id,province_name from ".$this->table." order by `province_sort` asc,`province_id` asc");
		return $list;
	}
	/*//添加品牌提交
	public function add_post()
	{
		$Model=M("Brand");
		$b_id=$Model->add($this->post);
		if($b_id<1){
			return false;
		}
		$data['b_id']=$b_id;
		$data['pc_id']=$this->post['pc_id'];
		$Model=M("Brand_class");
		if(!$Model->add($data)){
			return false;
		}
		return true;
	}
	//获取品牌列表
	public function get_list()
	{
		$page=intval($this->page);
		$perpage=intval($this->perpage);
		$Model=M("Brand");
		$start=($page-1)*$perpage;
		$list=$Model->query("select * from ".$this->table." order by `id` desc limit $start,$perpage");
		return $list;
	}
	//获得信息总数
	public function get_info_total()
	{
		$Model=M("Brand");
		$count=$Model->count();
		return $count;
	}
	//获取分类信息
	public function get_info()
	{
		$id=intval($this->id);
		$Model=M("Brand");
		$info=$Model->where('id='.$id)->find();
		return $info;
	}
	//提交编辑的内容
	public function edit_post()
	{
		$condition['id']= $this->post['id'];
		$data['name']=$this->post['name'];
		$data['sort']=$this->post['sort'];
		$data['seller_id']=$this->post['seller_id'];
		$data['is_recommend']=$this->post['is_recommend'];
		$data['is_show']=$this->post['is_show'];
		$data['is_apply']=$this->post['is_apply'];
		if($this->post['pic']){
			$data['pic']=$this->post['pic'];
		}
		$Model=M("Brand");
		$result=$Model->where($condition)->save($data);
		if($result === false) {
			return false;
		}
		//更新到brand_class表
		$Model=M("Brand_class");
		$condition['b_id']= $this->post['id'];
		$data['b_id']=$this->post['id'];
		$data['pc_id']=$this->post['pc_id'];
		$result=$Model->where($condition)->save($data);
		if($result === false) {
			return false;
		}
		return true;
	}
	//删除
	public function delete_ids()
	{
		$ids=$this->ids;
		$Model=M("Brand");
		foreach($ids as $v){
			$condition['id']=$v;
			if(!$Model->where($condition)->delete()){
				return false;
			}
		}
		return true;
	}*/

}